package org.ogv.usada.states;

import org.ogv.OGV;
import org.ogv.usada.models.GP;

import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

public class SplashScreen extends ScreenState {

	public SplashScreen(SpriteBatch sb) {
		super(sb);
		_id = GP.$().STATE_SPLASH;
	}
	
	@Override
	public void init() {
		//load texture
		_splash = OGV.asset.getTextureRegion(GP.$().RES_TEXR_SPLASH);
		
		//init doors
		initializeDoors();
	}

	@Override
	public void resume() {
		//Straight to be destroyed
		getStateMgr().requestPopState();
	}
	
	@Override
	public void run(float elapsedTime) {		
		//Draw
		_sb.begin();
		_sb.draw(_splash, 0, 0);
		if(areDoorsActive())
			drawDoors();
		_sb.end();
		
		//Wait ...
		updateDoors(elapsedTime);
		if(_timer > 0) {
			_timer -= elapsedTime;
			if(_timer <= 0) {
				requestStateChange(GP.$().STATE_START);
			}
		}
	}
	
	private TextureRegion _splash;
	private float _timer = 3;
}
